package com.rober.algorithm;

/**
 * @for 工厂模式
 * @author roberluo
 *
 */
public class FactoryModel {
	public static void main(String[] args) {
		Car2 bench = new BenchFactoty().getCar();
		Car2 baoma = new BaomaoFactoty().getCar();
		bench.name();
		baoma.name();
	}

}

// 车的名字
interface Car2{
	void name();
}

//车的工厂
interface CarFactoty2 {
	 Car2 getCar();
}

//奔驰-生产线
class bench2 implements Car2{
	@Override
	public void name() {
		System.out.println("I buy a bench");
	}
	
}

//宝马-生产线
class baoma2 implements Car2{
	@Override
	public void name() {
		System.out.println("I buy a baoma");
	}
}



class BenchFactoty implements CarFactoty2 {
	public Car2 getCar() {
		
		return new bench2();
	}
	
}

class BaomaoFactoty implements CarFactoty2 {
	public Car2 getCar() {
		
		return new baoma2();
	}
	
}